Please refer "Running Spark application on EC2 cluster" for detilas.